import socket
import json
from typing import List, Tuple

# 主机是192.168.32.1
# 从机是192.168.32.2
def main():
    host = "192.168.32.2"    
    port = 5010
    addr = (host, port)
    skt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    data_to_send = json.dumps([1, 2]).encode("utf-8")
    try:
        skt.sendto(data_to_send, addr)
        print(f"Sent data to {addr}: {data_to_send.decode('utf-8')}")
    except socket.error as e:
        print(f"Socket error: {e}")
    except Exception as e:
        print(f"An error occurred: {e}")
            
    skt.close()

if __name__ == "__main__":
    main()